
with open('data/problem011.txt') as file:
    list = map(int, file.read().split())
m = [list[i:i+20] for i in range(0, 400, 20)]

prods = []
for i in range(0, 17):
    for j in range(0, 17):
        prods += [m[i][j] * m[i][j+1] * m[i][j+2] * m[i][j+3]]
        prods += [m[i+3][j] * m[i+3][j+1] * m[i+3][j+2] * m[i+3][j+3]]
        prods += [m[i][j] * m[i+1][j] * m[i+2][j] * m[i+3][j]]
        prods += [m[i][j+3] * m[i+1][j+3] * m[i+2][j+3] * m[i+3][j+3]]
        prods += [m[i][j] * m[i+1][j+1] * m[i+2][j+2] * m[i+3][j+3]]
        prods += [m[i][j+3] * m[i+1][j+2] * m[i+2][j+1] * m[i+3][j]]

print max(prods) 

